package com.xjy.rpc.config;

import com.xjy.rpc.annotation.PropertiesField;
import com.xjy.rpc.annotation.PropertiesPrefix;

@PropertiesPrefix("rpc")
public class RpcProperties {

    /**
     * netty 端口
     */
    @PropertiesField
    private Integer port;

    /**
     * 注册中心地址
     */
    @PropertiesField("register-address")
    private String registerAddress;

    /**
     * 服务名称
     */
    @PropertiesField
    private String serviceName;

    /**
     * 服务注册过期时间
     */
    @PropertiesField("expire-time")
    private String expireTime;

    /**
     * 服务注册过期时间单位 TimeUnit里的枚举 second -> SECONDS hour -> HOURS
     */
    @PropertiesField("time-unit")
    private String timeUnit;

    /**
     *  注册中心用户名
     */
    @PropertiesField("name")
    private String name;


    /**
     *  注册中心密码
     */
    @PropertiesField("password")
    private String password;

    private RpcProperties(){}

    static volatile RpcProperties rpcProperties;
    public static RpcProperties getInstance(){
        if (rpcProperties == null){
            synchronized (RpcProperties.class){
                if (rpcProperties == null){
                    rpcProperties = new RpcProperties();
                }
            }
        }
        return rpcProperties;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public String getRegisterAddress() {
        return registerAddress;
    }

    public void setRegisterAddress(String registerAddress) {
        this.registerAddress = registerAddress;
    }

    public static RpcProperties getRpcProperties() {
        return rpcProperties;
    }

    public static void setRpcProperties(RpcProperties rpcProperties) {
        RpcProperties.rpcProperties = rpcProperties;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(String expireTime) {
        this.expireTime = expireTime;
    }

    public String getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(String timeUnit) {
        this.timeUnit = timeUnit;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassward() {
        return password;
    }

    public void setPassward(String passward) {
        this.password = passward;
    }
}
